Skip to content

Encoding: Fix _wp_scan_utf8() budget scanning#49

Open
sirreal wants to merge 11 commits into
trunkfrom
fix/utf8-scan-codepoint-budget
Open

Encoding: Fix _wp_scan_utf8() budget scanning#49
sirreal wants to merge 11 commits into
trunkfrom
fix/utf8-scan-codepoint-budget

Conversation

@sirreal

@sirreal sirreal commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Cap _wp_scan_utf8() ASCII fast-path scanning by the remaining code point budget.
  • Avoid scanning an entire ASCII run when callers request only a small number of code points.
  • Preserve returned spans and found code point counts for existing UTF-8 callers.

Testing

  • PHPUnit coverage for zero budgets, long ASCII runs, offsets, multibyte boundaries, and invalid spans.
  • Differential UTF-8 span validation and PHPCS pass.
  • codex review --base trunk.

Trac ticket: https://core.trac.wordpress.org/ticket/65372

Use of AI Tools

AI assistance: Yes
Tool(s): Claude, Codex
Model(s): Fable 5, GPT-5.5
Used for: Fuzz test design, diagnosis, PR description cleanup, and code review.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

sirreal added 2 commits June 11, 2026 12:34
When _wp_scan_utf8() is called with max_code_points but no max_bytes, the ASCII fast path previously called strspn() across the entire remaining ASCII run before checking the code point limit. This made _wp_utf8_codepoint_span( large ASCII text, 0, 5 ) scan the full string.

Bound strspn() by the remaining code point budget. ASCII code points are one byte, so this preserves the returned span and found count while avoiding work past the budget.

Local benchmark, 10 MB ASCII _wp_utf8_codepoint_span( ..., 0, 5 ): original 3.183709 ms, patched 0.001250 ms. Differential fuzz: 189847 span/found cases and 2750 valid mb_substr sanity cases, no mismatches.
@sirreal sirreal marked this pull request as ready for review June 11, 2026 11:26
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell, wildworks, sergeybiryukov, cbravobernal, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

sirreal and others added 9 commits June 15, 2026 11:09
Reject icon names that use uppercase letters, that lack a namespace prefix, or that have already been registered. Add tests covering these cases.

Props im3dabasia1, mukesh27, wildworks.
See #64847.


git-svn-id: https://develop.svn.wordpress.org/trunk@62515 602fd350-edb4-49c9-b593-d223f7449a82
Give interactive elements a consistent 40px height in the admin mobile viewport on the Add Plugins, Media Library grid, Settings > General, and Add Themes screens.

Follow-up to [61645].

Props abcd95, wildworks.
Fixes #64999.


git-svn-id: https://develop.svn.wordpress.org/trunk@62516 602fd350-edb4-49c9-b593-d223f7449a82
…ors.

Includes:
* Standardizing default values on `null` vs. `false`.
* Updating the documentation to correct parameter types.
* Adding missing parameter descriptions.

Follow-up to [22094].

Props Soean, mukesh27, SergeyBiryukov.
See #64897.

git-svn-id: https://develop.svn.wordpress.org/trunk@62517 602fd350-edb4-49c9-b593-d223f7449a82
Add `core/list-item` to the block attributes supported by block bindings so its `content` rich text can be bound, and cover the basic (non-nested) case in the render tests.

This is a clean enablement with no render-side changes. A List Item that contains a nested List keeps both inside the same `<li>`; preserving that nested list when `content` is bound is handled separately by the `WP_Block::replace_html()` inner-block fix.

Props sauliusv, cbravobernal.
See #65406.



git-svn-id: https://develop.svn.wordpress.org/trunk@62518 602fd350-edb4-49c9-b593-d223f7449a82
Developed in WordPress#12207.

Follow-up to [62507].

Props dmsnell.
See #64896.


git-svn-id: https://develop.svn.wordpress.org/trunk@62519 602fd350-edb4-49c9-b593-d223f7449a82
…locks.

The `wp_get_elements_class_name()` function previously generated CSS class names by hashing the serialized block data via `md5()`. Identical blocks received the same `wp-elements-*` class name and the Style Engine deduplicated their CSS rules into one, causing a parent block's element style (e.g. link color) to cascade down and override a child block's identical style due to CSS source order.

The function is updated to use `wp_unique_prefixed_id()` instead, generating sequential unique class names (`wp-elements-1`, `wp-elements-2`, etc.) that match the block editor's JavaScript implementation. The now-unused `$parsed_block` parameter is removed from the function signature.

PHPStan rule level 10 errors are also resolved in the related code. See #64898.

Developed in WordPress#12126.
Follow-up to r53260, r58074.

Props tusharbharti, westonruter, wildworks.
Fixes #65435.


git-svn-id: https://develop.svn.wordpress.org/trunk@62520 602fd350-edb4-49c9-b593-d223f7449a82
…ogo.

Adds gray WordPress logo image files (`w-logo-gray-white-bg.png` and `w-logo-gray-white-bg.svg`) to `wp-includes/images/`, and updates `the_embed_site_title()` and `do_favicon()` to use the new images as the fallback site icon, maintaining visual consistency with the login screen logo updated in r61989.

Replaces CSS custom property references for focus styles in the embed template (`--wp-admin-theme-color` and `--wp-admin-border-width-focus`) with their literal values, as these admin-theme variables are not defined in the oEmbed template context.

Developed in WordPress#11293.
Follow-up to r61652, r61989, r62502.

Props sabernhardt, huzaifaalmesbah, westonruter, jamesbregenzer.
See #64708.
Fixes #64877.


git-svn-id: https://develop.svn.wordpress.org/trunk@62521 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants